package com.bawei.erp.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bawei.erp.model.POrder;
import com.bawei.erp.service.POrderService;
import com.bawei.erp.service.StockService;
import com.bawei.util.JsonUtil;

@RestController
@RequestMapping("/porder")
public class POrderController {

	@Resource
	private POrderService pOrderService;

	@Resource
	private StockService stockService;

	@RequestMapping("/addPOrder")
	public String addPOrder(POrder order) {
		pOrderService.addPOrder(order);
		return JsonUtil.success();
	}

	@RequestMapping("/getPOrder")
	public String getPOrder() {
		return JsonUtil.success(pOrderService.getPOrder());
	}

	@RequestMapping("/stockIn")
	public String stockIn(String sku, String count, String type) {
		stockService.stockIn(sku, Integer.parseInt(count), Byte.valueOf(type));
		return JsonUtil.success();
	}

}
